//
//  BaseTableView.m
//  ChatForHot
//
//  Created by wr on 2018/10/10.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "BaseTableView.h"

@implementation BaseTableView

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
    if (self = [super initWithFrame:frame style:style]) {
        [self HOTCHATdefaultStyle];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        [self HOTCHATdefaultStyle];
    }
    return self;
}

- (void)HOTCHATdefaultStyle {
    UIColor *backgroundColor = nil;
    if (self.style == UITableViewStylePlain) {
        backgroundColor = [UIColor colorFromHexString:@"EFEFF4"];
        self.tableFooterView = [[UIView alloc] init];
    } else {
        backgroundColor = [UIColor colorFromHexString:@"EFEFF4"];
    }
    if (backgroundColor) {
        self.backgroundColor = [UIColor whiteColor];
    }
    self.separatorColor = [UIColor colorFromHexString:@"EFEFF4"];;
    self.backgroundView = [[UIView alloc] init];
    self.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    if (@available(iOS 11,*)) {
        self.estimatedRowHeight = 0;
        self.estimatedSectionHeaderHeight = 0;
        self.estimatedSectionFooterHeight = 0;
        self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
}

- (void)setTableFooterView:(UIView *)tableFooterView {
    ///< 保证一直存在tableFooterView，以去掉列表内容不满一屏时尾部的空白分割线
    if (!tableFooterView) {
        tableFooterView = [[UIView alloc] init];
    }
    [super setTableFooterView:tableFooterView];
}

@end
